﻿<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
    <script src="Scripts/md5.js" type="text/javascript"></script>
    <script src="Scripts/Math.uuid.js" type="text/javascript"></script>
</head>
<body>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#go').click(function () {

                var message = "<?xml version=\"1.0\" ?><Messages xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://tempuri.net/Headquarter.Messages\"><UpdatePrice><ProductId>23</ProductId></UpdatePrice></Messages>";
                var md5 = b64_md5(message) + "==";
                var clientId = Math.uuid() + "\\123456";

                $.ajax({
                    url: $('#gatewayaddress').val(),
                    data: {
                        Message: message,
                        "NServiceBus.CallType": "Submit",
                        "NServiceBus.AutoAck": "true",
                        "Content-MD5": md5,
                        "NServiceBus.Id": clientId,
                        "NServiceBus.TimeToBeReceived": "00:10:00"

                    },
                    dataType: 'jsonp',
                    success: function (data) {
                        if (data.status != "OK") {
                            alert("Failed to submit the request to the gateway");
                            return;
                        }
                        alert("Success - Check the output of the headquarter server process");
                    },
                    error: function (http, status) {
                        alert("Failed submit: " + status);
                    }
                }); //ajax

            });
        });
	</script>
    <h1>Click the button below to make a JSONP request to the nservicebus gateway</h1>
    <p>Gateway address:</p>
    <input type="text" id="gatewayaddress" value="http://localhost:25899/Headquarter/" size="60"/><br/>
    <input type="button" id="go" name="go" value="Send price update command to server" />
</body>
</html>
